<?php

/**
 * IndexController - The default controller class
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class Adminb_ScoreController extends Zend_Controller_Action 
{
	

	public function init(){
		
		$member=new CMember();
		
		if(!$member->isUser($this->_request->getModuleName(),$this->_request->getControllerName())){
			
			if($_COOKIE[COOKIE_PRE.'uid']!=''){
				
				$this->_redirect(MY_URL);
				
			}else{
			
				$this->_redirect(MY_URL.'/buyer-auth-login');
				
			}
			
		}
		
	}
	
	public function preDispatch()
	{
		
		$this->getHelper ('layout')->setLayout('framelayout');
		
		$this->view->addHelperPath(MY_ROOT.'/vhelpers');
		
		Zend_Controller_Action_HelperBroker::addPath(MY_ROOT.'/chelpers');
		
		$this->getHelper('User')->getinfo($this->view,$this->_request->getModuleName(),$this->_request->getControllerName());
		
	}
	
	public function indexAction(){
		
		$orderid=$this->_request->getParam('orderid');
		
		$this->view->assign('orderid',$orderid);
		
	}

	
	public function doscoreAction(){
		
		$this->_helper->viewRenderer->setNoRender();
		
		$orderid=$this->_request->getParam('orderid');
		
		$quality=$this->_request->getParam('quality');
		
		$delivery=$this->_request->getParam('delivery');
		
		$score=new CSellerScore('buyer');
		
		try{
			
			$data=array(
				'orderid'=>$orderid,
				'quality'=>$quality,
				'delivery'=>$delivery
			);
			
			$score->createSellerScore($data);
			
			/*增加虚拟货币*/
    		$give=new CBuyerGiveVirtual();
		
			$give->setUid($_COOKIE[COOKIE_PRE.'uid']);
		
			$order=new COrder();
			
			$orderArray=$order->getDetail($orderid);
			
			$orderArray[0]['money']=(int)$orderArray[0]['money'];
			
			$give->addBuyerSuccess($orderArray[0]['money']);
    		/*增加虚拟货币*/
			
		}catch(Exception $e){
			
			
			
		}
		
		$this->view->showMsg('Succeed to save！',$_SERVER['HTTP_REFERER']);
		
	}
	
	public function postAction(){
	
		//$this->_helper->viewRenderer->setNoRender();
		
		//$this->getHelper ('layout')->disableLayout ();
	
	}
    

    
}
